package gdkm.dao;

import kxc.gdkm.pojo.Resume;
import org.apache.ibatis.annotations.*;

import java.util.List;

public interface ResumeDAO {
    @Select("select * from resume where id = #{id}")
    @Results(id = "ResumeMap",value = {
            @Result(property = "user", column = "user_id",one = @One(select = "kxc.gdkm.dao.UserDAO.findById"))
    })
    Resume findById(Integer id);

    @Select("select * from resume")
    @ResultMap("ResumeMap")
    List<Resume> findAll();

    @Insert("INSERT INTO resume " +
            "(user_id, resume_name, template_id, education_experience, work_experience, project_experience, " +
            "skill, certificates, hobbies, language_ability, internship_experience, visibility,create_time,update_time) " +
            "VALUES " +
            "(#{userId}, #{resumeName}, #{templateId}, #{educationExperience}, #{workExperience}, #{projectExperience}, " +
            "#{skill}, #{certificates}, #{hobbies}, #{languageAbility}, #{internshipExperience}, #{visibility},#{createTime},#{updateTime})")
    boolean save(Resume resume);

    @Update("UPDATE resume " +
            "SET user_id = #{user.id}, resume_name = #{resumeName}, template_id = #{templateId}, education_experience = #{educationExperience}, " +
            "work_experience = #{workExperience}, project_experience = #{projectExperience}, " +
            "skill = #{skill}, certificates = #{certificates}, hobbies = #{hobbies}, language_ability = #{languageAbility}, " +
            "internship_experience = #{internshipExperience}, visibility = #{visibility},update_time = #{updateTime} "
    )
    boolean update(Resume resume);

    @Delete("DELETE FROM resume WHERE id = #{id}")
    boolean delete(Integer id);
}
